package com.fulihui.systemcore.repository.impl;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Repository;

import com.fulihui.systemcore.condition.WechatConfigCondition;
import com.fulihui.systemcore.dal.convertor.WechatConfigConv;
import com.fulihui.systemcore.dal.dataobj.WechatConfigDO;
import com.fulihui.systemcore.dal.mapper.WechatConfigMapper;
import com.fulihui.systemcore.dto.WechatConfig;
import com.fulihui.systemcore.enums.EnvTypeEnum;
import com.fulihui.systemcore.repository.WechatConfigRepository;
import com.fulihui.systemcore.request.wechat.WechatConfigSaveRequest;

/**
 * @author Created by Willard.Hu on 2016/6/2.
 */
@Repository
public class WechatConfigRepositoryImpl implements WechatConfigRepository {
    @Autowired
    private WechatConfigMapper wechatConfigMapper;

    @Override
    public void create(WechatConfigSaveRequest request) {
        // TODO WechatConfigRepository.create
    }

    @Override
    public boolean update(WechatConfigSaveRequest request) {
        // TODO WechatConfigRepository.update
        return false;
    }

    @Override
    public WechatConfig queryByPK(int id) {
        WechatConfigDO wechatConfigDO = wechatConfigMapper.queryByPK(id);
        return WechatConfigConv.toDTO(wechatConfigDO);
    }

    @Override
    public WechatConfig querySingle(String configCode, EnvTypeEnum envType) {
        WechatConfigDO wechatConfigDO = wechatConfigMapper.querySingle(configCode,
            envType.getCode());
        return WechatConfigConv.toDTO(wechatConfigDO);
    }

    @Override
    public List<WechatConfig> query(WechatConfigCondition condition) {
        WechatConfigDO conditionDO = WechatConfigConv.toDO(condition);
        List<WechatConfigDO> doList = wechatConfigMapper.query(conditionDO);
        return WechatConfigConv.toList(doList);
    }
}
